package com.qiwenshare.ufop.provider.util;


import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.http.HttpProtocol;
import com.qcloud.cos.region.Region;
import com.qiwenshare.ufop.provider.config.TencentConfig;

public class TencentUtils {

    private TencentUtils() {
        throw new UnsupportedOperationException("Cannot instantiate utility class");
    }

    public static COSClient getCOSClient(TencentConfig tencentConfig) {
        COSCredentials cred = new BasicCOSCredentials(tencentConfig.getCos().getAccessKeyId(), tencentConfig.getCos().getAccessKeySecret());
        Region region = new Region(tencentConfig.getCos().getEndpoint());
        ClientConfig clientConfig = new ClientConfig(region);
        clientConfig.setHttpProtocol(HttpProtocol.https);
        return new COSClient(cred, clientConfig);
    }

}
